package entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

@Entity
public class Quotation implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private Timestamp dateTime;
    private Integer daysValid;
    private Integer indicativeLeadTime; //in days
    @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private Collection<QuotationItem> quotationItems = new ArrayList<QuotationItem>();
    private String status;
    @OneToOne
    private Client client;
    private Boolean needDaysValid;
    private Boolean needLeadTime;
    private Double totalPrice;
    private String lastModifiedBy;

    public Quotation() {
        this.needDaysValid = true;
        this.needLeadTime = true;
        totalPrice =0.0;
     
    }

    public Integer getIndicativeLeadTime() {
        return indicativeLeadTime;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Quotation)) {
            return false;
        }
        Quotation other = (Quotation) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Quotation[ id=" + getId() + " ]";
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the dateTime
     */
    public Timestamp getDateTime() {
        return dateTime;
    }

    /**
     * @param dateTime the dateTime to set
     */
    public void setDateTime(Timestamp dateTime) {
        this.dateTime = dateTime;
    }

    /**
     * @return the daysValid
     */
    public Integer getDaysValid() {
        return daysValid;
    }

    /**
     * @param daysValid the daysValid to set
     */
    public void setDaysValid(Integer daysValid) {
        this.daysValid = daysValid;
    }

    /**
     * @param indicativeLeadTime the indicativeLeadTime to set
     */
    public void setIndicativeLeadTime(Integer indicativeLeadTime) {
        this.indicativeLeadTime = indicativeLeadTime;
    }

    /**
     * @return the quotationItems
     */
    public Collection<QuotationItem> getQuotationItems() {
        return quotationItems;
    }

    /**
     * @param quotationItems the quotationItems to set
     */
    public void setQuotationItems(Collection<QuotationItem> quotationItems) {
        this.quotationItems = quotationItems;
    }


    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }


    /**
     * @return the needDaysValid
     */
    public Boolean getNeedDaysValid() {
        return needDaysValid;
    }

    /**
     * @param needDaysValid the needDaysValid to set
     */
    public void setNeedDaysValid(Boolean needDaysValid) {
        this.needDaysValid = needDaysValid;
    }

    /**
     * @return the needLeadTime
     */
    public Boolean getNeedLeadTime() {
        return needLeadTime;
    }

    /**
     * @param needLeadTime the needLeadTime to set
     */
    public void setNeedLeadTime(Boolean needLeadTime) {
        this.needLeadTime = needLeadTime;
    }


    /**
     * @return the lastModifiedBy
     */
    public String getLastModifiedBy() {
        return lastModifiedBy;
    }

    /**
     * @param lastModifiedBy the lastModifiedBy to set
     */
    public void setLastModifiedBy(String lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    /**
     * @return the client
     */
    public Client getClient() {
        return client;
    }

    /**
     * @param client the client to set
     */
    public void setClient(Client client) {
        this.client = client;
    }

    /**
     * @return the totalPrice
     */
    public Double getTotalPrice() {
        return totalPrice;
    }

    /**
     * @param totalPrice the totalPrice to set
     */
    public void setTotalPrice(Double totalPrice) {
        this.totalPrice = totalPrice;
    }
}
